//  this library.
import 'package:hktk_app/ienum/practice/ct_enum.dart';
import 'package:hktk_app/ienum/question/first_type_enum.dart';
import 'package:hktk_app/model/practice/practice_question_model.dart';

/// 错题精选模型
class RankErrorModel {
  String? createdTime;
  String? modifyTime;
  int? id;
  int? categoryId;
  String? examId;
  String? questionId;
  FirstTypeEnum? type;
  String? questionSign;
  List<Stem>? stem;
  int? doCount;
  int? errorCount;
  int? collectCount;
  String? collectId;
  String? collectName;
  CtEnum? collectType;

  RankErrorModel({
    this.createdTime,
    this.modifyTime,
    this.id,
    this.categoryId,
    this.examId,
    this.questionId,
    this.type,
    this.questionSign,
    this.stem,
    this.doCount,
    this.errorCount,
    this.collectCount,
    this.collectId,
    this.collectName,
    this.collectType,
  });

  RankErrorModel.fromJson(Map<String, dynamic> json) {
    createdTime = json['createdTime'];
    modifyTime = json['modifyTime'];
    id = json['id'];
    categoryId = json['categoryId'];
    examId = json['examId'];
    questionId = json['questionId'];
    if (json["type"] != null) {
      type = FirstTypeEnum.getFirstType(json['type']);
    }
    questionSign = json['questionSign'];
    if (json['stem'] != null) {
      stem = <Stem>[];
      json['stem'].forEach((v) {
        stem!.add(Stem.fromJson(v));
      });
    }
    doCount = json['doCount'];
    errorCount = json['errorCount'];
    collectCount = json['collectCount'];
    collectId = json['collectId'];
    collectName = json['collectName'];
    if (json["collectType"] != null) {
      collectType = CtEnum.getTypeEnum(json['collectType']);
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['createdTime'] = createdTime;
    data['modifyTime'] = modifyTime;
    data['id'] = id;
    data['categoryId'] = categoryId;
    data['examId'] = examId;
    data['questionId'] = questionId;
    if (type != null) {
      data['type'] = type!.name;
    }
    data['questionSign'] = questionSign;
    if (stem != null) {
      data['stem'] = stem!.map((v) => v.toJson()).toList();
    }
    data['doCount'] = doCount;
    data['errorCount'] = errorCount;
    data['collectCount'] = collectCount;
    data['collectId'] = collectId;
    data['collectName'] = collectName;
    if (collectType != null) {
      data['collectType'] = collectType!.name;
    }
    return data;
  }
}
